<template>
	<view class="flex center between list">
		<view class="list-box" v-for="(numVal, index) in 2" :key="numVal">
			<view class="item-box" v-for="(item, j) in groupList[index]" :key="j"
				@click="toPage(`/pages_user/expert-detail?project=${JSON.stringify(nowProject)}&id=${item[nowProject.queryKey].id}`)">
				<view class="img-tip">
					<image :src="IMAGE_URL + '/static/login/bg.png'" class="img-tip" mode="widthFix" lazy-load></image>
					<view class="flex center like-icon">
						<i class="iconfont icon-xin font36"
							:style="{color: item[nowProject.queryKey].isCurrentUserThumpsUp == 1 ? '#FC2A51' : '#fff'}"
							@click.stop="likeFun(item[nowProject.queryKey])"></i>
					</view>
				</view>
				<view class="list-info">
					<view class="font28 fontbold-500 title ellipsis">
						婴儿车旧物低价处理
					</view>
					<view class="flex between" style="color: #999;">
						<view class="flex price font28">
							<text>￥</text>
							<text class="font36">63</text>
							<text>.10</text>
						</view>
						<view class="font20">8人浏览过</view>
					</view>
					<view class="flex center start">
						<image :src="IMAGE_URL + '/static/login/bg.png'" class="avatar"></image>
						<view class="font20 nickname">12121</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import appConfig from '@/config/app.js'
	export default {
		data() {
			return {
				IMAGE_URL: appConfig.IMAGE_URL,
				list: [],
				groupList: [
					[],
					[]
				]
			}
		},
		components: {},
		methods: {
			init() {
				const resultData = [{
					name: 1
				}, {
					name: 1
				}, {
					name: 1
				}, {
					name: 1
				}, {
					name: 1
				}]
				const group = this.dynamicGrouping(resultData)
				this.groupList = this.groupList.map((i, index) => {
					return [...i, ...group[index]]
				})
			},
			dynamicGrouping(data, i = 2) {
				console.log(data)
				const groups = [];
				for (let j = 0; j < i; j++) {
					groups.push([]);
				}
				for (let k = 0; k < data.length; k++) {
					const groupIndex = k % i;
					groups[groupIndex].push(data[k]);
				}
				return groups;
			},
			scrollPage() {
				// if (this.loading) return
				// this.loading = true
				// this.params.pageNum = this.params.pageNum + 1
			},
		},
		mounted() {
			this.init()
		},
		watch: {
			params: {
				handler() {
					this.init()
				},
				deep: true
			}
		},
	}
</script>

<style lang="scss" scoped>
	.scroll-box {
		height: calc(100vh - 127rpx);
	}

	.list {
		margin: 20rpx 12rpx;
		align-items: flex-start;

		.list-box {
			width: calc((100% - 10rpx) / 2);
			color: #333;

			.item-box {
				width: 100%;
				padding-bottom: 16rpx;
				margin-bottom: 12rpx;
				background: #fff;
				border-radius: 16rpx;
				position: relative;
			}

			.img-tip {
				border-radius: 16rpx 16rpx 0rpx 0rpx;
				width: 100%;
				position: relative;
			}

			.list-info {
				margin: 0 16rpx;
			}

			.price {
				height: 48rpx;
				border-radius: 10rpx;
				color: $uni-text-color-red;
				align-items: baseline;
				font-weight: 500;
				margin: 8rpx 0;

				.font20 {
					color: $uni-text-color-grey;
					text-decoration-line: line-through;
					margin-left: 4rpx;
				}
			}

			.avatar {
				width: 24rpx;
				height: 24rpx;
				border-radius: 50%;
				margin-right: 4rpx;
			}

			.nickname {
				color: #999999;
			}
		}
	}
</style>